package org.scirp.ijmis.dao.personpaper.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.scirp.ijmis.dao.base.impl.BaseDAOImpl;
import org.scirp.ijmis.dao.personpaper.ISendEmailLogDAO;
import org.scirp.ijmis.po.personpaper.SendEmailLog;

public class SendEmailLogDAOImpl extends BaseDAOImpl<SendEmailLog> implements ISendEmailLogDAO {
	private static final String className = SendEmailLog.class.toString();

	public Long saveSendEmailLog(SendEmailLog sendEmailLog) {
		return super.saveObject(sendEmailLog, className + "--->saveSendEmailLog(SendEmailLog sendEmailLog)");
	}

	public List<SendEmailLog> selectAllByPaperId(Long paperId) {
		String hql = "from SendEmailLog where paper.pid=:paperId order by pid desc";

		Map parameters = new HashMap();
		parameters.put("paperId", paperId);

		return super.ExecuteQuery(hql, parameters, className + "--->selectAllByPaperId");
	}

	public List<SendEmailLog> selectAllByPaperIdAndTypeId(Long paperId, Long emailTypeId) {
		String hql = "from SendEmailLog where paper.pid=:paperId and emailType.pid=:emailTypePId order by pid desc";

		Map<String, Long> parameters = new HashMap<String, Long>();
		parameters.put("paperId", paperId);
		parameters.put("emailTypePId", emailTypeId);

		return super.ExecuteQuery(hql, parameters, className + "--->selectAllByPaperIdAndTypeId");
	}

	public List<SendEmailLog> selectAllByToEmail(String toEmail) {
		String hql = "from SendEmailLog where toEmail=:toEmail order by pid desc";

		Map<String, String> parameters = new HashMap<String, String>();
		parameters.put("toEmail", toEmail);

		return super.ExecuteQuery(hql, parameters, className + "--->selectAllByToEmail");
	}

}
